/**
 * @param {number[]} obstacles
 * @return {number[]}
 */
 var longestObstacleCourseAtEachPosition = function(obstacles) {
  const n = obstacles.length
  const dp = new Array(n).fill(1)
  for(let i = 1; i<n; i++){
    for(let j = i-1; j>=0; j--){
      if(obstacles[i] >= obstacles[j]){
        dp[i] = Math.max(dp[i], dp[j] + 1)
      }
    }
  }
  return dp
};